<?php
/* Används av save.php och vid avinstalleration av paketet */
	
$apache2_siteconf = "/etc/apache2/sites-available/default";
$str_conf = file_get_contents($apache2_siteconf);

if( preg_match('/\s*documentroot\s*([^\s]*)\s*/i', $str_conf , $match) < 1 ) {
	echo "Kunde inte läsa konfiguration\n";
}
else {
	$old_directory = $match[1];

	$str_conf = preg_replace('/(\s*<directory )('.str_replace('/', '\/', $old_directory).')([\/ >]*.*?allow from )([^\s]*)/ism', '$1$2$3none', $str_conf);
	file_put_contents( $apache2_siteconf, $str_conf );
	exec('/usr/bin/setfacl -R -x u:www-data '.$old_directory."\n");
	exec('/usr/bin/setfacl -R -x d:u:www-data '.$old_directory."\n");
	exec("/etc/init.d/apache2 restart &\n");
}
?>
